package org.sabayframework.mem.impl;

import java.lang.reflect.Field;

import sun.misc.Unsafe;

public abstract class UnsafeBigBuffer extends AbstractBigBuffer {

	static final Unsafe unsafe;
    static
    {
        try
        {
            Field field = Unsafe.class.getDeclaredField("theUnsafe");
            field.setAccessible(true);
            unsafe = (Unsafe)field.get(null);
        }
        catch (Exception e)
        {
            throw new RuntimeException(e);
        }
    }
 
    static final long byteArrayOffset = unsafe.arrayBaseOffset(byte[].class);
    static final long shortArrayOffset = unsafe.arrayBaseOffset(short[].class);
    static final long charArrayOffset = unsafe.arrayBaseOffset(char[].class);
    static final long intArrayOffset = unsafe.arrayBaseOffset(int[].class);
    static final long floatArrayOffset = unsafe.arrayBaseOffset(float[].class);
    static final long longArrayOffset = unsafe.arrayBaseOffset(long[].class);
    static final long doubleArrayOffset = unsafe.arrayBaseOffset(double[].class);
 
    static final long SIZE_OF_SHORT = 2;
    static final long SIZE_OF_CHAR = 2;
    static final long SIZE_OF_INT = 4;
    static final long SIZE_OF_FLOAT = 4;
    static final long SIZE_OF_LONG = 8;
    static final long SIZE_OF_DOUBLE = 8;

	public UnsafeBigBuffer(long pos, long lim, long cap) {
		super(pos, lim, cap);
	}


}
